package com.xyd.Biz.Impl;

import com.xyd.Biz.CommodityBiz;
import com.xyd.Dao.CommodityDao;
import com.xyd.Entity.Commodity;
import com.xyd.Entity.Page;
import com.xyd.Util.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class CommodityBizImpl implements CommodityBiz {
    SqlSession sqlSession = null;
    CommodityDao commodityDao = null;

    public CommodityBizImpl() {
        sqlSession = SqlSessionFactoryUtil.open();
        commodityDao = sqlSession.getMapper(CommodityDao.class);
    }


    @Override
    public Commodity SerachCommodityById(int id) {
        return commodityDao.SerachCommodityById(id);
    }

    @Override
    public List<Commodity> getAllCommodity() {
        return commodityDao.getAllCommodity();
    }

    @Override
    public int updateCommodityInventory(int num, int commodity_id) {
        return commodityDao.updateCommodityInventory(num, commodity_id);
    }

    @Override
    public List<Commodity> getAllCommodityInCar() {
        return commodityDao.getAllCommodityInCar();
    }


    @Override
    public int removeProductClassById(Commodity commodity) {
        return commodityDao.removeProductClassById(commodity);
    }

    @Override
    public int updateProductById(Commodity commodity) {
        return commodityDao.updateProductById(commodity);
    }

    @Override
    public int addProduct(Commodity commodity) {
        return commodityDao.addProduct(commodity);
    }

    @Override
    public int getCommodityCount() {
        return commodityDao.getCommodityCount();
    }

    @Override
    public List<Commodity> getAllCommodityByPage(Page page) {
        return commodityDao.getAllCommodityByPage(page);
    }
}
